home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / Action Atoms [inaa] Example / myActionAtoms.r < prev    next >
Encoding:
Text File  |  1996-09-30  |  8.0 KB  |  286 lines  |  [TEXT/MPS ]

  1. //
  2. //    myActionAtoms.r
  3. //
  4. //        Purpose : Demonstrate use of the three types of action atoms.
  5. //
  6. //        There are four selectable packages in Custom Install. Each
  7. //        package calls one of the three formats of action atoms. Each
  8. //        action atom will be called before install, and will not be 
  9. //        called at all when performing a custom remove.
  10. //
  11. //        A dialog is provided that will allow the user to choose which
  12. //        value should be returned from the current action atom.
  13. //
  14. //        NOTE: Displaying dialogs from within action atoms and other
  15. //        code resources is discouraged.  Installer scripts that
  16. //        display dialogs from within code resources will not work
  17. //        when running under Installer Engine 4.1.  This example shows
  18. //        you how you can write action atom code that will display a
  19. //        dialog under Installer 4.0.3 and still be compatible with
  20. //        Installer Engine 4.1.  For more information on script
  21. //        compatibility with Installer Engine 4.1 see the "Engine 4.1
  22. //        Compatiblity Issues" document in the Installer 4.1 folder of
  23. //        the Installer SDK.
  24. //
  25. //        The third Custom Install option includes Installer Debugger
  26. //        example code within the action atom to display status and
  27. //        progress information to the Installer Debugger during execution
  28. //        of the action atom. To observe this feature, drag drop a copy
  29. //        of the debugger version of the installer script onto a copy of
  30. //        the installer application that contains the Wasabi Installer 
  31. //        Debugger.
  32. //
  33. //        The fourth option calls an action atom that displays progress
  34. //        in the Installer dialog progress bar while the action atom is
  35. //        running.
  36. //
  37. //        NOTE: A file atom has been included with each action
  38. //        atom in the three packages. Action atoms can, however,
  39. //        be included in packages by themselves. 
  40. //
  41. //        Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
  42. //
  43.  
  44. #include "InstallerTypes.r"
  45.  
  46. // custom install framework always uses ID of 766
  47. resource 'infr' (766) {
  48.     format0 {{
  49.         pickFirst, { 700 },            // adds Example File to custom install options
  50.     }}
  51. };
  52.  
  53. // • rules
  54.  
  55. // rule that adds package with the subpackages
  56. resource 'inrl' (700) {
  57.     format0 {{
  58.         AddCustomItems{{ 100,200,300,400 }},
  59.     }}
  60. };
  61.  
  62.  
  63. // • packages
  64.  
  65. resource 'inpk' (100) {
  66.     format0 {
  67.         showsOnCustom,
  68.         removable,
  69.         dontForceRestart,
  70.         0,
  71.         0,
  72.         "Run action atom format 0 - with Example File",
  73.         {    
  74.         'infa', 1000;
  75.         'inaa', 9000;
  76.         },
  77.     }
  78. };
  79.  
  80. resource 'inpk' (200) {
  81.     format0 {
  82.         showsOnCustom,
  83.         removable,
  84.         dontForceRestart,
  85.         0,
  86.         0,
  87.         "Run action atom format 1 - with Example File",
  88.         {    
  89.         'infa', 1000;
  90.         'inaa', 9001;
  91.         },
  92.     }
  93. };
  94.  
  95. resource 'inpk' (300) {
  96.     format0 {
  97.         showsOnCustom,
  98.         removable,
  99.         dontForceRestart,
  100.         0,
  101.         0,
  102.         "Run action atom format 2 - with Example File",
  103.         {    
  104.         'infa', 1000;
  105.         'inaa', 9002;
  106.         },
  107.     }
  108. };
  109.  
  110. resource 'inpk' (400) {
  111.     format0 {
  112.         showsOnCustom,
  113.         removable,
  114.         dontForceRestart,
  115.         0,
  116.         0,
  117.         "Progress Bar action atom ( format2 ) - with Example File",
  118.         {    
  119.         'infa', 1000;
  120.         'inaa', 9003;
  121.         },
  122.     }
  123. };
  124.  
  125.  
  126.  
  127. // • file atoms
  128.  
  129. // file atom for Example File ( same file atom used for all packages )
  130. resource 'infa' (1000) {
  131.     format1 {
  132.         deleteWhenRemoving,            // Delete existing file on remove
  133.         deleteWhenInstalling,        // Delete existing file on install
  134.         copy,                        // Copy on Install
  135.         dontIgnoreLockedFile,        // Respect file locking
  136.         dontSetFileLocked,            // Don't lock installed file
  137.         useSrcCrDateToCompare,        // Use date for comparisons
  138.         srcNeedExist,                // Never create new file ( update only )
  139.         rsrcForkInRsrcFork,            // Put resources in resource fork
  140.         leaveAloneIfNewer,            // Do not update a newer file
  141.         updateExisting,                // Update an existing file
  142.         copyIfNewOrUpdate,            // Copy whether it preexists or not
  143.         rsrcFork,                    // Copy or Remove resource fork
  144.         dataFork,                    // Copy or Remove data fork
  145.         0,                            // File size            
  146.         0x0,                        // File Finder attributes
  147.         11001,                        // Target spec ( 'intf' )
  148.         {    
  149.             11000,                     // Source spec ( 'infs' )
  150.             0,                         // Data fork size
  151.             0                        // Resource fork size
  152.         },
  153.         0,                            // Source version number in BCD format
  154.         0,                            // Version compare resource ID
  155.         0,                            // Atom extender resource ID
  156.         "Example File"                    // Atom description
  157.     }
  158. };
  159.  
  160.  
  161. // • file specs
  162.  
  163. // target file spec for teach text application
  164. resource 'intf' (11001) {
  165.     format1 {
  166.         noSearchForFile,                 // use default search path
  167.         
  168.         TypeCrMustMatch,                 // If this is set to TypeCrMustMatch
  169.                                         // then a file with a different type
  170.                                         // and creator will not be replaced.
  171.                                         // If this is set to TypeCrNeedNotMatch
  172.                                         // then type and creator of an existing
  173.                                         // target file are ignored.
  174.         
  175.         // The Type and Creator fields will be used to set the
  176.         // file's Type and Creator when a new file is created. 
  177.         'ttro',                         // TYPE for new file
  178.         'ttxt',                         // CREATOR for new file
  179.         
  180.         0,                                 // finder attribute flags
  181.                                         // filled by ScriptCheck is value is 0
  182.         
  183.         1,                                  // creation date for new file
  184.         1,                                  // modification date for new file
  185.                                         // NOTE: DATE values are filled
  186.                                         // by ScriptCheck if the value is 1
  187.                                             
  188.         0,                                 // search proc ID ( 'insp' ), none used
  189.         
  190.         ":ActionAtom Example:Example File"    // path to target file
  191.         }
  192.     };
  193.  
  194. // source file spec for teach text application
  195. resource 'infs' (11000) {
  196.     'ttro',                        // TYPE for source file
  197.     'ttxt',                        // CREATOR for source file
  198.     0x1,                        // creation DATE for source file
  199.     noSearchForFile,            // IGNORED in Installer 4.0.x
  200.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  201.     "Disk 1:Example File"        // PATH to source file        
  202. };
  203.  
  204.  
  205. // • action atoms
  206.  
  207. // format0 action atom
  208. include "myActionAtom_0.rsrc";
  209.  
  210. // format1 action atom
  211. include "myActionAtom_1.rsrc";
  212.  
  213. // format2 action atom
  214. include "myActionAtom_2.rsrc";
  215.  
  216. // format2 action atom
  217. include "ProgressAtom.rsrc";
  218.  
  219. resource 'inaa' ( 9000 ) {
  220.     format0{
  221.         actBefore,                // when to run action atom
  222.         dontActOnRemove,        // run action atom on removal
  223.         actOnInstall,            // run action atom on install
  224.         'infn',                    // resource type of code resource
  225.         9000,                    // resource ID of code resource
  226.         0,                        // refcon ID
  227.         "action atom format 0"    // description of atom
  228.     }
  229. };
  230.  
  231. resource 'inaa' ( 9001 ) {
  232.     format1{
  233.         suspendBusyCursors,        // how to handle cursor during atom
  234.         actBefore,                // when to run action atom
  235.         dontActOnRemove,        // run action atom on removal
  236.         actOnInstall,            // run action atom on install
  237.         'infn',                    // resource type of code resource
  238.         9001,                    // resource ID of code resource
  239.         1,                        // refcon ID
  240.         "action atom format 1"    // description of atom
  241.     }
  242. };
  243.  
  244. resource 'inaa' ( 9002 ) {
  245.     format2{
  246.         suspendBusyCursors,        // how to handle cursor during atom
  247.         actBefore,                // when to run action atom
  248.         dontActOnRemove,        // run action atom on removal
  249.         actOnInstall,            // run action atom on install
  250.         'infn',                    // resource type of code resource
  251.         9002,                    // resource ID of code resource
  252.         2,                        // refcon ID
  253.         
  254.         // NOTE: Enter zero for this value to use the installer's heap,
  255.         // or enter size in bytes to have this action atom use it's own heap.
  256.         // All earlier action atom formats use the installer's heap.
  257.         // IMPORTANT: enter zero for this field unless you have a specific
  258.         // reason for your action atom to use memory from it's own heap.
  259.         0,                        // requested memory in bytes
  260.                 
  261.         
  262.         "action atom format 2"    // description of atom
  263.     }
  264. };
  265.  
  266. resource 'inaa' ( 9003 ) {
  267.     format2{
  268.         suspendBusyCursors,        // how to handle cursor during atom
  269.         actBefore,                // when to run action atom
  270.         dontActOnRemove,        // run action atom on removal
  271.         actOnInstall,            // run action atom on install
  272.         'infn',                    // resource type of code resource
  273.         9003,                    // resource ID of code resource
  274.         3,                        // refcon ID
  275.         
  276.         // NOTE: Enter zero for this value to use the installer's heap,
  277.         // or enter size in bytes to have this action atom use it's own heap.
  278.         // All earlier action atom formats use the installer's heap.
  279.         // IMPORTANT: enter zero for this field unless you have a specific
  280.         // reason for your action atom to use memory from it's own heap.
  281.         0,                        // requested memory in bytes
  282.                 
  283.         
  284.         "progress bar action atom"    // description of atom
  285.     }
  286. };